package com.example.service.util.conversion;

import com.example.common.util.enums.BusinessEnum;
import com.example.common.util.exception.BusinessException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @Author juzipi
 * @Date 2021/7/28 8:46
 * @Info
 */
public class FeignResultConversion {



    public static <T> T convertResult(Object bean, Class<T> clazz){
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            return objectMapper.convertValue(bean,clazz);
        } catch (Exception e) {
            e.printStackTrace();
            throw new BusinessException(BusinessEnum.CONVERT_ERROR);
        }
    }

}
